<script setup>
import { ref } from 'vue';

const props = defineProps({ isVisible: Boolean });
const emit = defineEmits(['save', 'close']);

const configForm = ref({ speed: 200, count: 1 });

const saveConfig = () => {
  emit('save', configForm.value);
};

const closeConfig = () => {
  emit('close');
};
</script>

<template>
  <div v-show="isVisible" class="config-mask" @click="closeConfig">
    <div class="config-box" @click.stop>
      <h3>游戏配置</h3>
      <div class="config-item">
        <label>移动速度（ms/步）：</label>
        <input type="number" v-model.number="configForm.speed" min="50" max="500" />
      </div>
      <div class="config-item">
        <label>食物数量：</label>
        <input type="number" v-model.number="configForm.count" min="1" max="5" />
      </div>
      <div class="config-item">
        <label>食物颜色：</label>
        <input type="color" v-model="configForm.foodColor" />
      </div>
      <div class="config-item">
        <label>粒子颜色：</label>
        <input type="color" v-model="configForm.particleColor" />
      </div>
      <div class="config-btns">
        <button @click="saveConfig" class="save-btn">保存配置</button>
        <button @click="closeConfig" class="cancel-btn">取消</button>
      </div>
    </div>
  </div>
</template>

<style scoped>
.config-mask {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.config-box {
  background: #ffffff;
  padding: 40px;
  border-radius: 18px;
  min-width: 450px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
  transform: translateY(-5px);
}

.config-box h3 {
  text-align: center;
  color: #2c3e50;
  margin-bottom: 25px;
}

.config-item {
  margin-bottom: 25px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.config-item label {
  color: #34495e;
  font-weight: 500;
  min-width: 120px;
}

.config-item input {
  padding: 12px 16px;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  flex: 1;
  font-size: 16px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05);
  transition: all 0.3s;
}
.config-item input:focus {
  border-color: #2c3e50;
  box-shadow: 0 0 0 2px rgba(44, 62, 80, 0.1);
  outline: none;
  background: #f9fafb;
}

.config-btns {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 25px;
}

.save-btn {
  padding: 12px 24px;
  background: #28a745;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  font-size: 16px;
}

.cancel-btn {
  padding: 12px 24px;
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  font-size: 16px;
}

.save-btn:hover,
.cancel-btn:hover {
  transform: scale(1.05);
}
</style>